/*****************************************************
Copyright (C) 2020. All rights reserved.
File name     ：HuffmanTree.h
Version       ：v1.0
Author        ：zhengqijun
Date          ：2020-04-26
Function List ：
Description   ：Huffman Tree
******************************************************/

#ifndef HUFFMANTREE_H_
#define HUFFMANTREE_H_

// Type Definition
struct HeapStruct;
typedef int ElementType;
typedef struct TreeNode *HeapElementType;
typedef struct HeapStruct *PriorityQueue;
typedef struct TreeNode *Position;
typedef struct TreeNode *HuffmanTree;

// MinHeap Function Lists
PriorityQueue Initialize(int MaxElements);
void Destroy(PriorityQueue H);
void MakeEmpty(PriorityQueue H);
void Insert(HeapElementType X, PriorityQueue H);
HeapElementType DeleteMin(PriorityQueue H);
HeapElementType FindMin(PriorityQueue H);
PriorityQueue BuildHeap(HeapElementType A[], int N);
void DecreaseKey(int P, HeapElementType X, PriorityQueue H);
void IncreaseKey(int P, HeapElementType X, PriorityQueue H);
void Delete(int P, PriorityQueue H);
int IsEmpty(PriorityQueue H);
int IsFull(PriorityQueue H);
int Size(PriorityQueue H);
HeapElementType Retrieve(PriorityQueue H, int Index);

// HuffmanTree Function Lists
HuffmanTree CreateNode(int Weight);
HuffmanTree Huffman(PriorityQueue H);
HuffmanTree MakeEmptyTree(HuffmanTree T);
Position Left(Position P);
Position Right(Position P);
int Weight(Position P);

#endif  /* HUFFMANTREE_H_ */

// EOF

